home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++,comp.os.ms-windows.programmer.misc
- Path: cs.mun.ca!michael9
- From: michael9@cs.mun.ca (Michael Sullivan)
- Subject: Help with FindNextPrinterChange
- Message-ID: <1996Mar19.232159.25236@cs.mun.ca>
- Keywords: C, MS Windows
- Sender: usenet@cs.mun.ca (NNTP server account)
- Organization: CS Dept., Memorial University of Newfoundland
- X-Newsreader: NN version 6.4.19
- Distribution: na
- Date: Tue, 19 Mar 1996 23:21:59 GMT
-
-
- Hi there. I'm new to programming for MS Windows, and have run into the
- following problem: in the code below, the call to FindFirstPrinterChange
- returns a 0x000000 value. Which seems to be useless as a handle, but isn't
- equal to the INVALID_CHANGE_HANDLE that it should return when the call fails.
- Can someone tell me what I'm doing wrong? How about sending me a sample
- file that uses FindFirstPrinterChange? I'm currently using MS Visual C++ 4.0.
-
-
- #include <stdio.h>
- #include <afx.h>
- #include <winspool.h>
- void main()
- {
- HANDLE changeHandle;
- HANDLE printer;
-
-
- int i =0;
-
- if ( ! OpenPrinter("LPT1:", &printer, NULL) )
- {
- fprintf(stderr, "Error opening printer.\n");
- }
-
- changeHandle = FindFirstPrinterChangeNotification(printer,
- PRINTER_CHANGE_ADD_JOB, (DWORD) 0, NULL);
-
- /* at this point, changeHandle is 0x0, which is not INV_HNDL. */
-
- if (changeHandle == 0 ) printf("Change failed\n");
-
- if ( changeHandle == INVALID_HANDLE_VALUE )
- {
- fprintf(stderr, "Can't open change handle.\n");
- }
-
- while ( i++ < 3)
- {
- if ( (w = WaitForSingleObject(changeHandle, INFINITE)) == WAIT_FAILED);
- {
- // of course, this always fails
- printf("wait failed\n");
- }
-
- printf("Got ya!\n");
- }
-
-
- }
-
-
- I've tried various typecasts, and tried creating an LPHANDLE and assigning
- it the address of changeHandle before calling OpenPrinter, but that
- didn't work either. Advice?
-
-
- --
- |michael9@cs.mun.ca |'"Proof denies faith and without faith I am nothing,"|
- |13 Liverpool,St.John's,NF| says God. "But you have given us proof," says man, |
- |A1C 3B1 (H)739-4185 (W)579-2730| "Therefore you do not exist. QED." "Oh, my,"|
- |http://web.cs.mun.ca/~michael9 | says God, and disappears in a puff of logic.'|
-